/**
 * 
 */
package com.ccrc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ccrc.lang.Data;
import com.ccrc.lang.Pager;
import com.ccrc.model.UserTab;
import com.ccrc.service.IUserTabService;

/**
 * 用户管理，用管理用户信息 控制器
 * @author Jalen
 * @time 2017-03-30 10:39
 *
 */
@Controller
@RequestMapping("/userTab")
public class UserTabController extends BaseController {
	
	@Autowired
	private IUserTabService userTabService;

	@RequestMapping("/list")
	public String userTabList(Model model) {
		//TODO
		return "userTab/userTab_list";
	}
	
	@RequestMapping("/ajaxPage")
	@ResponseBody
	public Pager getPageUserTab(int rows, int page) {
		Pager pager = new Pager(rows, page);
		userTabService.getPageUserTab(pager);
		return pager;
	}

	@RequestMapping("/ajaxAdd")
	@ResponseBody
	public Data ajaxAddUserTab(UserTab userTab) {
		userTabService.addUserTab(userTab);
		return Data.success("添加信息成功！");
	}

	@RequestMapping("/ajaxModify")
	@ResponseBody
	public Data ajaxModifyUserTab(UserTab userTab) {
		userTabService.modifyUserTab(userTab);
		return Data.success("修改信息成功！");
	}

	@RequestMapping("/ajaxRemove")
	@ResponseBody
	public Data ajaxRemoveUserTab(Long userId) {
		userTabService.removeUserTab(userId);
		return Data.success("删除信息成功！");
	}

	@RequestMapping("/ajaxGet")
	@ResponseBody
	public Data ajaxGetUserTabByUserId(Long userId) {
		return Data.success(userTabService.getUserTabByUserId(userId));
	}

	@RequestMapping("/ajaxFind")
	@ResponseBody
	public Data ajaxFindUserTabByUserId(Long userId) {
		return Data.success(userTabService.getUserTabByUserId(userId));
	}

	@RequestMapping("/ajaxGetUserTabByAgeUserName")
	@ResponseBody
	public Data ajaxGetUserTabByAgeUserName(Integer age, String userName) {
		return Data.success(userTabService.getUserTabByAgeUserName(age, userName));
	}

	@RequestMapping("/ajaxFindUserTabByGenderUserName")
	@ResponseBody
	public Data ajaxFindUserTabByGenderUserName(Integer gender, String userName) {
		return Data.success(userTabService.findUserTabByGenderUserName(gender, userName));
	}

}